﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AG.Data;

namespace AGMapEditor.Controls
{
    public partial class AGSwitchPointPanel : UserControl, IMapPanelObserver
    {
        private AGEMapPanel _ctlMapPanel;
        public AGSwitchPointPanel(AGEMapPanel mapPanel)
        {
            InitializeComponent();

            _ctlMapPanel = mapPanel;
            _ctlMapPanel.Attach(this);
        }

        public void UpdateDesignState()
        {
        }

        public void UpdateObjectList()
        {
        }

        public void UpdateSwitchPointList()
        {
            BindSwitchPointList();
        }

        private void BindSwitchPointList()
        {
            _ctlListSP.Items.Clear();
            for (int index = 0; index < _ctlMapPanel.Map.SwitchPoints.Count; index++)
            {
                _ctlListSP.Items.Add(_ctlMapPanel.Map.SwitchPoints[index]);
            }
        }

        private void _ctlListSP_SelectedIndexChanged(object sender, EventArgs e)
        {
            AGMapSwitchPoint selSP = _ctlListSP.SelectedItem as AGMapSwitchPoint;
            if (selSP != null)
            {
                _ctlMapPanel.SelectSwitchPoint(selSP);
            }
        }
    }
}
